import { configureStore } from "@reduxjs/toolkit";
import counter from "@/store/modules/counter";
import {TypedUseSelectorHook, useDispatch, useSelector} from "react-redux";
import recommend from "@/views/discover/c-views/recommend/store/recommend";
import player from "@/views/player/store/player";

const store = configureStore({
  reducer: {
    counter,
    recommend,
    player
  }
});

// store.getStore 为一个返回 reducer 类型的函数 返回值是 reducer 类型
export type IRootState = ReturnType<typeof store.getState>;
export type IRootDispatch = typeof store.dispatch;
// 自定义绑定类型的 useSelector 和 useDispatch
export const useAppSelector: TypedUseSelectorHook<IRootState> = useSelector;
export const useAppDispatch: () => IRootDispatch = useDispatch;

export default store;
